package com.winit.jumpServer.task;

import com.winit.common.util.*;
import com.winit.jumpServer.bean.PushRecordInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;

/**
 * 查询推送进度
 * Created by wangjian on 16/1/18.
 */
public class PushProgressTask implements Runnable {

    private static final Logger logger = LoggerFactory.getLogger(PushProgressTask.class);

    private PushRecordInfo pushRecordInfo;

    public PushProgressTask(PushRecordInfo pushRecordInfo){
        this.pushRecordInfo = pushRecordInfo;
    }

    public void run() {
        logger.info("查询推送进度开启......");
        logger.info("参数：pushRecordInfo="+ ObjectToString.getString(pushRecordInfo));
        BufferedReader reader = null;
        StringBuffer str = new StringBuffer();
        try {
            FileInputStream fileInputStream = new FileInputStream("/Users/wangjian/Desktop/scp.log");
            InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");
            reader = new BufferedReader(inputStreamReader);
            String tempString = null;
            while((tempString = reader.readLine()) != null){
                System.out.println("======::"+tempString);
                tempString = tempString.replace(" ","");
                tempString = tempString.replace("push.tgz","");
                String[] a = tempString.split("%");
                System.out.println(tempString);
                System.out.println(a[0]);
            }
            reader.close();
        }catch (Exception e){
            logger.error("读取json文件异常,e:"+e.getMessage());
        }finally{
            if(reader != null) {
                try {
                    reader.close();
                } catch (Exception e) {
                    logger.error("读取json文件异常,e:"+e.getMessage());
                }
            }
        }
        logger.info("查询推送进度结束......");
    }

}
